package com.ruoyi.web.controller.fire;

import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.fire.domain.dto.UplinkDataDTO;
import com.ruoyi.fire.service.IDGatewayMessageService;
import com.ruoyi.fire.service.IDWaterMessageService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import static com.ruoyi.common.core.domain.AjaxResult.success;

@RestController
@RequiredArgsConstructor
@RequestMapping("/device/data")
@Api(value = "DGatewayMessageController",tags = "设备上行数据")
public class DGatewayMessageController {

    private final IDGatewayMessageService gatewayMessageService;
    private final IDWaterMessageService waterMessageService;

    @ApiOperation("网关设备上行数据")
    @PostMapping ("/gatewayUplinkData")
    public AjaxResult gatewayUplinkData(@RequestBody UplinkDataDTO uplinkDataDTO) {
        return success(gatewayMessageService.uplinkData(uplinkDataDTO));
    }

    @ApiOperation("水协议设备上行数据")
    @PostMapping("/waterUplinkData")
    public AjaxResult waterUplinkData(@RequestBody UplinkDataDTO uplinkDataDTO) {
        return success(waterMessageService.uplinkData(uplinkDataDTO));
    }

    @ApiOperation("水池设备是否在线")
    @GetMapping("/OnlineStatus/{deviceNo}")
    public AjaxResult OnlineStatus(@PathVariable String deviceNo) {
        return AjaxResult.success(waterMessageService.OnlineStatus(deviceNo));
    }
}
